home *** CD-ROM | disk | FTP | other *** search
/ Workbench Add-On / Workbench Add-On - Volume 1.iso / Dev / Oberon / source / amiga / LowLevel.mod < prev    next >
Text File  |  1995-06-29  |  9KB  |  356 lines

  1. (*************************************************************************
  2.  
  3.      $RCSfile: LowLevel.mod $
  4.   Description: Interface to lowlevel.library
  5.  
  6.    Created by: fjc (Frank Copeland)
  7.     $Revision: 3.7 $
  8.       $Author: fjc $
  9.         $Date: 1995/06/04 23:13:14 $
  10.  
  11.   Includes Release 40.15
  12.  
  13.   (C) Copyright 1993 Commodore-Amiga, Inc.
  14.       All Rights Reserved
  15.  
  16.   Oberon-A Interface Copyright © 1994-1995, Frank Copeland.
  17.   This file is part of the Oberon-A Interface.
  18.   See Oberon-A.doc for conditions of use and distribution.
  19.  
  20. *************************************************************************)
  21.  
  22. <* STANDARD- *>
  23.  
  24. MODULE [2] LowLevel;
  25.  
  26. IMPORT
  27.   SYS := SYSTEM, Kernel, e := Exec, u := Utility, t := Timer, s := Sets;
  28.  
  29. (*
  30. **      $VER: lowlevel.h 40.6 (30.7.93)
  31. **
  32. **      lowlevel.library interface structures and definitions.
  33. *)
  34.  
  35. (*****************************************************************************)
  36.  
  37. TYPE
  38.  
  39. (* structure for use with QueryKeys() *)
  40.   KeyQueryPtr * = POINTER TO KeyQuery;
  41.   KeyQuery * = RECORD
  42.     keyCode * : e.UWORD;
  43.     pressed * : e.BOOL;
  44.   END;
  45.  
  46.  
  47. (*****************************************************************************)
  48.  
  49. CONST
  50.  
  51. (* bits in the return value of GetKey() *)
  52.   lShift * = 16;
  53.   rShift * = 17;
  54.   capsLock * = 18;
  55.   control * = 19;
  56.   lAlt * = 20;
  57.   rAlt * = 21;
  58.   lAmiga * = 22;
  59.   rAmiga * = 23;
  60.  
  61.  
  62. (*****************************************************************************)
  63.  
  64. CONST
  65.  
  66. (* Tags for SetJoyPortAttrs() *)
  67.   sjaDummy * = u.user + 0C00100H;
  68.   sjaType * = sjaDummy+1;             (* force type to mouse, joy, game cntrlr *)
  69.   sjaReinitialize * = sjaDummy+2;     (* free potgo bits, reset to autosense   *)
  70.  
  71. (* Controller types for sjaType tag *)
  72.   sjaTypeAutoSense * = 0;
  73.   sjaTypeGameCtlr * = 1;
  74.   sjaTypeMouse * = 2;
  75.   sjaTypeJoystk * = 3;
  76.  
  77.  
  78. (*****************************************************************************)
  79.  
  80. CONST
  81.  
  82. (* ReadJoyPort() return value definitions *)
  83.  
  84. (* Port types *)
  85.   typeNotAvail * = 0;               (* port data unavailable    *)
  86.   typeGameCtlr * = 010000000H;      (* port has game controller *)
  87.   typeMouse    * = 020000000H;      (* port has mouse           *)
  88.   typeJoyStk   * = 030000000H;      (* port has joystick        *)
  89.   typeUnknown  * = 040000000H;      (* port has unknown device  *)
  90.   typeMask     * = 0F0000000H;      (* controller type          *)
  91.  
  92. (* Button types, valid for all types except JP_TYPE_NOTAVAIL *)
  93.   buttonBlue    * = 23;        (* Blue - Stop; Right Mouse                *)
  94.   buttonRed     * = 22;        (* Red - Select; Left Mouse; Joystick Fire *)
  95.   buttonYellow  * = 21;        (* Yellow - Repeat                         *)
  96.   buttonGreen   * = 20;        (* Green - Shuffle                         *)
  97.   buttonForward * = 19;        (* Charcoal - Forward              *)
  98.   buttonReverse * = 18;        (* Charcoal - Reverse              *)
  99.   buttonPlay    * = 17;        (* Grey - Play/Pause; Middle Mouse         *)
  100.   buttonMask    * = { buttonBlue, buttonRed, buttonYellow,
  101.                      buttonGreen, buttonForward, buttonReverse,
  102.                      buttonPlay };
  103.  
  104. (* Direction types, valid for jpTypeGamectlr and jpTypeJoystk *)
  105.   joyUp    * = 3;
  106.   joyDown  * = 2;
  107.   joyLeft  * = 1;
  108.   joyRight * = 0;
  109.   directionMask * = {joyUp, joyDown, joyLeft, joyRight};
  110.  
  111. (* Mouse position reports, valid for jpTypeMouse *)
  112.   mHorzMask * = 0FFH;                  (* horzizontal position *)
  113.   mVertMask * = 0FF00H;                (* vertical position    *)
  114.   mouseMask * = mHorzMask + mVertMask;
  115.  
  116. (* Obsolete ReadJoyPort() definitions, here for source code compatibility only.
  117.  * Please do NOT use in new code.
  118.  *)
  119.   btn1 *  = buttonBlue;
  120.   btn2 *  = buttonRed;
  121.   btn3 *  = buttonYellow;
  122.   btn4 *  = buttonGreen;
  123.   btn5 *  = buttonForward;
  124.   btn6 *  = buttonReverse;
  125.   btn7 *  = buttonPlay;
  126.   up *    = joyUp;
  127.   down *  = joyDown;
  128.   left *  = joyLeft;
  129.   right * = joyRight;
  130.  
  131.  
  132. (*****************************************************************************)
  133.  
  134. CONST
  135.  
  136. (* Tags for SystemControl() *)
  137.   sconDummy *         = u.user + 000C00000H;
  138.   sconTakeOverSys *   = sconDummy+0;
  139.   sconKillReq *       = sconDummy+1;
  140.   sconCDReboot *      = sconDummy+2;
  141.   sconStopInput *     = sconDummy+3;
  142.   sconAddCreateKeys * = sconDummy+4;
  143.   sconRemCreateKeys * = sconDummy+5;
  144.  
  145. (* Reboot control values for use with SCON_CDReboot tag *)
  146.   cdRebootOn *      = 1;
  147.   cdRebootOff *     = 0;
  148.   cdRebootDefault * = 2;
  149.  
  150.  
  151. (*****************************************************************************)
  152.  
  153. CONST
  154.  
  155. (* Rawkey codes returned when using sconAddCreateKeys with SystemControl() *)
  156.  
  157.   port0ButtonBlue * = 072H;
  158.   port0ButtonRed * = 078H;
  159.   port0ButtonYellow * = 077H;
  160.   port0ButtonGreen * = 076H;
  161.   port0ButtonForward * = 075H;
  162.   port0ButtonReverse * = 074H;
  163.   port0ButtonPlay * = 073H;
  164.   port0JoyUp * = 079H;
  165.   port0JoyDown * = 07AH;
  166.   port0JoyLeft * = 07CH;
  167.   port0JoyRight * = 07BH;
  168.  
  169.   port1ButtonBlue * = 0172H;
  170.   port1ButtonRed * = 0178H;
  171.   port1ButtonYellow * = 0177H;
  172.   port1ButtonGreen * = 0176H;
  173.   port1ButtonForward * = 0175H;
  174.   port1ButtonReverse * = 0174H;
  175.   port1ButtonPlay * = 0173H;
  176.   port1JoyUp * = 0179H;
  177.   port1JoyDown * = 017AH;
  178.   port1JoyLeft * = 017CH;
  179.   port1JoyRight * = 017BH;
  180.  
  181.   port2ButtonBlue * = 0272H;
  182.   port2ButtonRed * = 0278H;
  183.   port2ButtonYellow * = 0277H;
  184.   port2ButtonGreen * = 0276H;
  185.   port2ButtonForward * = 0275H;
  186.   port2ButtonReverse * = 0274H;
  187.   port2ButtonPlay * = 0273H;
  188.   port2JoyUp * = 0279H;
  189.   port2JoyDown * = 027AH;
  190.   port2JoyLeft * = 027CH;
  191.   port2JoyRight * = 027BH;
  192.  
  193.   port3ButtonBlue * = 0372H;
  194.   port3ButtonRed * = 0378H;
  195.   port3ButtonYellow * = 0377H;
  196.   port3ButtonGreen * = 0376H;
  197.   port3ButtonForward * = 0375H;
  198.   port3ButtonReverse * = 0374H;
  199.   port3ButtonPlay * = 0373H;
  200.   port3JoyUp * = 0379H;
  201.   port3JoyDown * = 037AH;
  202.   port3JoyLeft * = 037CH;
  203.   port3JoyRight * = 037BH;
  204.  
  205.  
  206. (*****************************************************************************)
  207.  
  208. CONST
  209.  
  210. (* Return values for GetLanguageSelection() *)
  211.   langUnknown * = 0;
  212.   american * = 1;           (* American English *)
  213.   english * = 2;            (* British English  *)
  214.   german * = 3;
  215.   french * = 4;
  216.   spanish * = 5;
  217.   italian * = 6;
  218.   portuguese * = 7;
  219.   danish * = 8;
  220.   dutch * = 9;
  221.   norwegian * = 10;
  222.   finnish * = 11;
  223.   swedish * = 12;
  224.   japanese * = 13;
  225.   chinese * = 14;
  226.   arabic * = 15;
  227.   greek * = 16;
  228.   hebrew * = 17;
  229.   korean * = 18;
  230.  
  231.  
  232. (*****************************************************************************)
  233.  
  234. (*-- Library Base variable --------------------------------------------*)
  235.  
  236. CONST
  237.  
  238.   lowlevelName * = "lowlevel.library";
  239.  
  240. VAR
  241.  
  242.   base* : e.LibraryPtr;
  243.  
  244.  
  245. (*-- Library Functions ------------------------------------------------*)
  246.  
  247. TYPE
  248.   (* some dummys for type security *)
  249.   KBIntHandle     * = POINTER TO RECORD END;
  250.   TimerIntHandle  * = POINTER TO RECORD END;
  251.   VBlankIntHandle * = POINTER TO RECORD END;
  252.  
  253.   (* easy handling of GetKey() result *)
  254.   KeyDescription * = RECORD
  255.     qualifier *: s.SET16;
  256.     code      *: INTEGER;
  257.   END;
  258.  
  259. (*
  260. **      $VER: lowlevel_protos.h 40.6 (30.7.93)
  261. *)
  262.  
  263. (*--- functions in V40 or higher (Release 3.1) ---*)
  264.  
  265. (* CONTROLLER HANDLING *)
  266.  
  267. PROCEDURE ReadJoyPort* [base,-30]
  268.   ( port [0] : e.ULONG )
  269.   : s.SET32;
  270.  
  271. (* LANGUAGE HANDLING *)
  272.  
  273. PROCEDURE GetLanguageSelection* [base,-36] ()
  274.   : SHORTINT;
  275.  
  276. (* KEYBOARD HANDLING *)
  277.  
  278. PROCEDURE GetKey* [base,-48] ()
  279.   : e.ULONG;
  280. PROCEDURE QueryKeys* [base,-54]
  281.   ( queryArray [8] : KeyQueryPtr;
  282.     arraySize  [1] : e.ULONG );
  283. PROCEDURE AddKBInt* [base,-60]
  284.   ( intRoutine [8] : e.PROC;
  285.     intData    [9] : e.APTR )
  286.   : KBIntHandle;
  287. PROCEDURE RemKBInt* [base,-66]
  288.   ( intHandle [9] : KBIntHandle );
  289.  
  290. (* SYSTEM HANDLING *)
  291.  
  292. PROCEDURE SystemControlA* [base,-72]
  293.   ( tagList [9] : ARRAY OF u.TagItem )
  294.   : u.TagID;
  295. PROCEDURE SystemControl* [base,-72]
  296.   ( tagList [9]..: u.Tag )
  297.   : u.TagID;
  298.  
  299. (* TIMER HANDLING *)
  300.  
  301. PROCEDURE AddTimerInt* [base,-78]
  302.   ( intRoutine [8] : e.PROC;
  303.     intData    [9] : e.APTR )
  304.   : TimerIntHandle;
  305. PROCEDURE RemTimerInt* [base,-84]
  306.   ( intHandle [9] : TimerIntHandle );
  307. PROCEDURE StopTimerInt* [base,-90]
  308.   ( intHandle [9] : TimerIntHandle );
  309. PROCEDURE StartTimerInt* [base,-96]
  310.   ( intHandle    [9] : TimerIntHandle;
  311.     timeInterval [0] : e.ULONG;
  312.     continuous   [1] : e.LONGBOOL );
  313. PROCEDURE ElapsedTime* [base,-102]
  314.   ( VAR context [8] : t.EClockVal )
  315.   : e.ULONG;
  316.  
  317. (* VBLANK HANDLING *)
  318.  
  319. PROCEDURE AddVBlankInt* [base,-108]
  320.   ( intRoutine [8] : e.PROC;
  321.     intData    [9] : e.APTR )
  322.   : VBlankIntHandle;
  323. PROCEDURE RemVBlankInt* [base,-114]
  324.   ( intHandle [9] : VBlankIntHandle );
  325.  
  326. (* MORE CONTROLLER HANDLING *)
  327.  
  328. PROCEDURE SetJoyPortAttrsA* [base,-132]
  329.   ( portNumber [0] : e.ULONG;
  330.     tagList    [9] : ARRAY OF u.TagItem )
  331.   : BOOLEAN;
  332. PROCEDURE SetJoyPortAttrs* [base,-132]
  333.   ( portNumber [0]  : e.ULONG;
  334.     tagList    [9]..: u.Tag )
  335.   : BOOLEAN;
  336.  
  337. (* only a dummy to make sure SIZE(KeyDescriptor) = SIZE(LONGINT) *)
  338. PROCEDURE [0] CheckKeyDescriptorSize(kd: KeyDescription): LONGINT;
  339. BEGIN
  340.   RETURN SYS.VAL(LONGINT,kd);
  341. END CheckKeyDescriptorSize;
  342.  
  343. (*-- Library Base variable --------------------------------------------*)
  344.  
  345. (*-----------------------------------*)
  346. PROCEDURE* [0] CloseLib (VAR rc : LONGINT);
  347.  
  348. BEGIN (* CloseLib *)
  349.   IF base # NIL THEN e.CloseLibrary (base) END
  350. END CloseLib;
  351.  
  352. BEGIN
  353.   base := e.OpenLibrary (lowlevelName, e.libraryMinimum);
  354.   IF base # NIL THEN Kernel.SetCleanup (CloseLib) END
  355. END LowLevel.
  356.